// 授权登录缓存
let oauthCache: string[] | null = null;

// 获取授权登录服务列表
export const getOauthServiceProvider = async () => {
    return new Promise<string[]>(resolve => {
        uni.getProvider({
            service: 'oauth',
            success({ provider }) {
                oauthCache = provider;
                resolve(provider);
            },
        });
    });
};

// 判断授权登录服务是否可用
export const hasOauthService = async (service: string) => {
    if (oauthCache) return oauthCache.includes(service);
    const provider = await getOauthServiceProvider();
    return provider.includes(service);
};
